#include <iostream>
#include <vector>

using namespace std;

const int N = 110;

vector<int> a[N];

int n, m;

int main()
{
	cin >> n >> m;
	
	while (n -- )
	{
		int op;
		cin >> op;
		
		if (op == 1)
		{
			int T;
			cin >> T;
			
			while (T -- )
			{
				int c, t;
				cin >> c >> t;
				a[c].push_back(t);
			}
		}
		else 
		{
			int res = 0;
			int c, l, r;
		
			cin >> c >> l >> r;
			
			for (auto x : a[c])
			{
				if (x >= l && x <= r) res ++ ;
			}
			cout << res << endl;
		}
	}
	
	return 0;
}